package com.zhongshengnetwork.rightbe.clerk.adapter;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.amap.api.maps2d.model.Text;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.target.DrawableImageViewTarget;
import com.bumptech.glide.request.transition.Transition;
import com.zhongshengnetwork.rightbe.Constant.APIKey;
import com.zhongshengnetwork.rightbe.CustomApplication;
import com.zhongshengnetwork.rightbe.R;
import com.zhongshengnetwork.rightbe.common.AppThemeUtils;
import com.zhongshengnetwork.rightbe.common.CircleTransform;
import com.zhongshengnetwork.rightbe.common.CommonUtils;
import com.zhongshengnetwork.rightbe.common.ScreenUtils;
import com.zhongshengnetwork.rightbe.common.customview.CustomDialog;
import com.zhongshengnetwork.rightbe.common.expandabletextview.ExpandableTextView;
import com.zhongshengnetwork.rightbe.gsonmodel.LangInfoModel;
import com.zhongshengnetwork.rightbe.https.HttpCallBack;
import com.zhongshengnetwork.rightbe.https.HttpsUtils;
import com.zhongshengnetwork.rightbe.lang.activity.LangDetailActivity;
import com.zhongshengnetwork.rightbe.lang.activity.LangPublishActivity;
import com.zhongshengnetwork.rightbe.lang.activity.SelfImagePreviewActivity;
import com.zhongshengnetwork.rightbe.lang.activity.UserLangActivity;
import com.zhongshengnetwork.rightbe.login.LoginActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import pl.droidsonroids.gif.GifImageView;

public class ClerkAdapter extends RecyclerView.Adapter<ClerkAdapter.ViewHolder> {

    public List<LangInfoModel> mList;

    private Activity mActivity;

    private int imgW = 0;

    static class ViewHolder extends RecyclerView.ViewHolder{

        FrameLayout lang_user_header_layout;
        ImageView lang_user_header;
        ImageView private_icon;
        TextView lang_user_nickname;
        TextView lang_time;
        Button lang_care;
        ExpandableTextView lang_content;
        LinearLayout lang_op_layout;
        Button lang_op1;
        FrameLayout up_img_layout;
        ImageView up_img_1;
        RelativeLayout lang_share;
        TextView lang_share_text;
        RelativeLayout lang_collect;
        ImageView lang_collect_img;
        TextView lang_collect_text;
        RelativeLayout lang_like;
        ImageView lang_like_img;
        TextView lang_like_text;
        RelativeLayout lang_comment;
        ImageView lang_share_comment;
        TextView lang_comment_text;

        public ViewHolder(View view){
            super(view);
            lang_user_header_layout = (FrameLayout) view.findViewById(R.id.lang_user_header_layout);
            lang_user_header = (ImageView) view.findViewById(R.id.lang_user_header);
            private_icon = (ImageView) view.findViewById(R.id.private_icon);
            lang_user_nickname = (TextView) view.findViewById(R.id.lang_user_nickname);
            lang_time = (TextView) view.findViewById(R.id.lang_time);
            lang_care = (Button) view.findViewById(R.id.lang_care);
            lang_content = (ExpandableTextView) view.findViewById(R.id.lang_content);
            lang_op_layout = (LinearLayout) view.findViewById(R.id.lang_op_layout);
            lang_op1 = (Button) view.findViewById(R.id.lang_op1);
            up_img_layout = (FrameLayout) view.findViewById(R.id.up_img_layout);
            up_img_1 = (ImageView) view.findViewById(R.id.up_img_1);
            lang_share = (RelativeLayout) view.findViewById(R.id.lang_share);
            lang_share_text = (TextView) view.findViewById(R.id.lang_share_text);
            lang_collect = (RelativeLayout) view.findViewById(R.id.lang_collect);
            lang_collect_img = (ImageView) view.findViewById(R.id.lang_collect_img);
            lang_collect_text = (TextView) view.findViewById(R.id.lang_collect_text);
            lang_like = (RelativeLayout) view.findViewById(R.id.lang_like);
            lang_like_img = (ImageView) view.findViewById(R.id.lang_like_img);
            lang_like_text = (TextView) view.findViewById(R.id.lang_like_text);
            lang_comment = (RelativeLayout) view.findViewById(R.id.lang_comment);
            lang_share_comment = (ImageView) view.findViewById(R.id.lang_share_comment);
            lang_comment_text = (TextView) view.findViewById(R.id.lang_comment_text);
        }

    }

    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.clert_item_layout,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position){

        LangInfoModel model = mList.get(position);
        if (!CommonUtils.isEmpty(model.getPrivateIcon())){
            holder.private_icon.setVisibility(View.VISIBLE);
            Glide.with(mActivity).load(model.getPrivateIcon()).transform(new CircleTransform(mActivity)).dontAnimate().into(holder.private_icon);
        }else {
            holder.private_icon.setVisibility(View.GONE);
        }
        holder.lang_user_header_layout.setTag(position);
        holder.lang_user_header_layout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickUser((int)v.getTag());
            }
        });
        /*
        Object nameTag = holder.lang_user_nickname.getTag();
        if (nameTag == null || (int)nameTag == position){
            holder.lang_user_nickname.setText(model.getNickname());
        }else {
            holder.lang_user_nickname.setText("");
            holder.lang_user_nickname.setText(model.getNickname());
        }
        */
        holder.lang_user_nickname.setText(model.getNickname());
        holder.lang_user_nickname.setTag(position);
        holder.lang_user_nickname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickUser((int)v.getTag());
            }
        });
        holder.lang_care.setTag(position);
        holder.lang_care.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCare((int)v.getTag());
            }
        });
        Glide.with(mActivity).load(model.getHeader()).transform(new CircleTransform(mActivity)).dontAnimate().into(holder.lang_user_header);

        //最新全部展示时间
        if (!CommonUtils.isEmpty(model.getSign())){
            holder.lang_time.setText(model.getSign()+" · 阅读量: "+model.getExploreCount());
        }else {
            holder.lang_time.setText("阅读量: "+model.getExploreCount());
        }

        if (model.iscare() == true){
            holder.lang_care.setVisibility(View.INVISIBLE);
        }else {
            holder.lang_care.setVisibility(View.VISIBLE);
        }
        if (CommonUtils.isEmpty(model.getTitle())){
            holder.lang_content.setVisibility(View.GONE);
        }else {
            holder.lang_content.setVisibility(View.VISIBLE);
            holder.lang_content.setText(model.getTitle(),position);
        }

        holder.lang_op1.setTag(position);
        holder.lang_op1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickDelete((int)v.getTag());
            }
        });
        if (model.isMy() == true){
            holder.lang_op_layout.setVisibility(View.VISIBLE);
            holder.lang_op1.setVisibility(View.VISIBLE);
        }else {
            holder.lang_op_layout.setVisibility(View.GONE);
            holder.lang_op1.setVisibility(View.GONE);
        }

        holder.up_img_layout.setVisibility(View.GONE);

        if (model.getImglist() == null){

        }else if (model.getImglist().size() > 0){
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_1.setVisibility(View.VISIBLE);
            holder.up_img_layout.setVisibility(View.VISIBLE);
            holder.up_img_layout.setTag(position+",1");
            holder.up_img_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("TAG","点击了图片:"+v.getTag());
                    onClickImageView(v);
                }
            });
            ViewGroup.LayoutParams layoutParams = holder.up_img_layout.getLayoutParams();
            ViewGroup.LayoutParams params = holder.up_img_1.getLayoutParams();
            if (model.getScaleSize() > 1.0){
                params.width = (int)(imgW*0.6);
                params.height = (int)Math.round(imgW*0.6 * model.getScaleSize());
            }else {
                params.width = ViewGroup.LayoutParams.MATCH_PARENT;
                //int height = Math.round(imgW / Configs.Value.IMAGE_WIDTH_HEIGHT_RATIO);
                int height = (int)Math.round(imgW * model.getScaleSize());
                params.height = height;
            }
            holder.up_img_1.setLayoutParams(params);
            layoutParams.width = params.width;
            layoutParams.height = params.height;
            holder.up_img_layout.setLayoutParams(layoutParams);

            try{
                if (model.getImglist().get(0).contains(".gif")){
                    /*
                    String imgTag = (String) holder.up_img_1.getTag();
                    if (CommonUtils.isEmpty(imgTag) || imgTag.equals(model.getImglist().get(0))){
                        holder.up_img_1.setTag(model.getImglist().get(0));
                        Glide.with(mActivity).asGif().load(model.getImglist().get(0)).
                                diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                    }else {
                        holder.up_img_1.setImageDrawable(ContextCompat.getDrawable(mActivity, AppThemeUtils.getInstance().getDefaultImageBg()));
                        Glide.with(mActivity).asGif().load(model.getImglist().get(0)).
                                diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                    }
                    */
                    //Glide.with(mActivity).asGif().load(model.getImglist().get(0)).
                            //diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                    Glide.with(mActivity).load(model.getImglist().get(0)).
                            diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).dontAnimate().centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                }else {
                    /*
                    String imgTag = (String) holder.up_img_1.getTag();
                    if (CommonUtils.isEmpty(imgTag) || imgTag.equals(model.getImglist().get(0))){
                        holder.up_img_1.setTag(model.getImglist().get(0));
                        Glide.with(mActivity).asBitmap().load(model.getImglist().get(0)).
                                diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).dontAnimate().centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                    }else {
                        holder.up_img_1.setImageDrawable(ContextCompat.getDrawable(mActivity, AppThemeUtils.getInstance().getDefaultImageBg()));
                        Glide.with(mActivity).asBitmap().load(model.getImglist().get(0)).
                                diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).dontAnimate().centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);
                    }
                    */
                    Glide.with(mActivity).load(model.getImglist().get(0)).
                            diskCacheStrategy(DiskCacheStrategy.RESOURCE).skipMemoryCache(false).dontAnimate().centerCrop().placeholder(AppThemeUtils.getInstance().getDefaultImageBg()).into(holder.up_img_1);

                }
            }catch (Exception e){
                LangPublishActivity.uploadError("加载gif图片报错："+e.getLocalizedMessage());
            }

        }

        if (model.getSharecount() == 0){     holder.lang_share_text.setText("分享"); }else {     holder.lang_share_text.setText(CommonUtils.getDisplayCount(model.getSharecount())); }

        if (model.iscollect() == true){
            holder.lang_collect_img.setImageResource(R.drawable.collection_sel);
            holder.lang_collect_text.setTextColor(ContextCompat.getColor(mActivity,R.color.lightGreenColor));
        }else {
            holder.lang_collect_img.setImageResource(R.drawable.collection);
            holder.lang_collect_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getCollectcount() == 0){     holder.lang_collect_text.setText("收藏"); }else {     holder.lang_collect_text.setText(CommonUtils.getDisplayCount(model.getCollectcount())); }

        if (model.islike() == true){
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like_sel);
            holder.lang_like_text.setTextColor(ContextCompat.getColor(mActivity,R.color.lightGreenColor));
        }else {
            holder.lang_like_img.setImageResource(R.drawable.workgroup_img_like);
            holder.lang_like_text.setTextColor(AppThemeUtils.getInstance().getSmallTextColor());
        }
        if (model.getLikecount() == 0){
            holder.lang_like_text.setText("喜欢");
        }else {     holder.lang_like_text.setText(CommonUtils.getDisplayCount(model.getLikecount())); }

        if (model.getCommentcount() == 0){     holder.lang_comment_text.setText("评论"); }else {     holder.lang_comment_text.setText(CommonUtils.getDisplayCount(model.getCommentcount())); }
        holder.lang_share.setTag(position);
        holder.lang_share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickShare((int)v.getTag(),v);
            }
        });

        holder.lang_collect.setTag(position);
        holder.lang_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickCollect((int)v.getTag());
            }
        });

        holder.lang_like.setTag(position);
        holder.lang_like.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickLike((int)v.getTag());
            }
        });

        holder.lang_comment.setTag(position);
        holder.lang_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onClickDetail((int)v.getTag());
            }
        });

    }

    @Override
    public int getItemCount(){
        return mList.size();
    }

    public ClerkAdapter(Activity a, int w){
        if (mList == null){
            mList = new ArrayList<LangInfoModel>();
        }
        mActivity = a;
        imgW = w;
    }

    public void addList(List<LangInfoModel> list){
        if (mList == null){
            mList = new ArrayList<LangInfoModel>();
        }
        if (list != null && list.size() > 0){
            mList.addAll(list);
        }
    }

    //点击图片处理
    private void onClickImageView(final View view){

        if (mActivity == null){
            return;
        }

        if (mList == null || mList.size() == 0){
            return;
        }

        if (CustomApplication.isWatchingImg == true){
            return;
        }
        CustomApplication.isWatchingImg = true;

        String tag = view.getTag().toString();
        List<String> l = CommonUtils.stringToArrayList(tag);
        LangInfoModel model = mList.get(Integer.valueOf(l.get(0)));
        String mSamllImg = model.getImgEnd();
        int position = Integer.valueOf(l.get(1))-1;
        Intent intent = new Intent(mActivity, SelfImagePreviewActivity.class);
        intent.putExtra("position",position);
        intent.putExtra("isListImg",true);
        List<String> list = CommonUtils.stringToArrayList(model.getImg());
        intent.putExtra("imgs",list.get(0));
        //View代表方法传入的控件
        int[] viewLocation = new int[2];
        view.getLocationInWindow(viewLocation);
        int viewX = viewLocation[0]; // x 坐标
        int viewY = viewLocation[1]-(int) (20* ScreenUtils.getScreenDensity(CustomApplication.mContext)); // y 坐标，这里当顶部有状态栏时，要减去状态栏的高度
        intent.putExtra("viewX",viewX);
        intent.putExtra("viewY",viewY);
        intent.putExtra("imgW",imgW);
        intent.putExtra("imgH",imgW);
        mActivity.startActivity(intent);
        mActivity.overridePendingTransition(0,0);//可以通过参数设置关闭与要显示的动画效果,0表示无效果.


    }

    //点击头像和昵称
    private void onClickUser(int position){
        if (mActivity == null){
            return;
        }

        if (mList == null || mList.size() == 0){
            return;
        }
        LangInfoModel model = mList.get(position);
        //进入个人主页
        Intent intent = new Intent(mActivity, UserLangActivity.class);
        intent.putExtra(APIKey.useridKey,model.getUserid());
        intent.putExtra(APIKey.typeKey,1);
        intent.putExtra(APIKey.titleKey,model.getNickname());
        mActivity.startActivity(intent);
    }


    //点击删除
    private void onClickDelete(final int position){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(mActivity, LoginActivity.class);
            mActivity.startActivity(intent);
            return;
        }

        CustomDialog dialog = null;
        final CustomDialog.Builder builder = new CustomDialog.Builder(mActivity);
        builder.setTitle("温馨提示");
        builder.setMessage("确定要删除？");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                deleteIndex(position);
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog = builder.create();
        dialog.show();
    }
    private void deleteIndex(final int position){
        if (mList == null || mList.size() == 0){
            return;
        }
        LangInfoModel model = mList.get(position);
        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put(APIKey.idKey, model.getLangid());
        String url = "miniapp/"+"langappid"+"/deletelanginfo.do";

        mList.remove(position);
        notifyDataSetChanged();
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    //点击关注
    private void onClickCare(final int position){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(mActivity, LoginActivity.class);
            mActivity.startActivity(intent);
            return;
        }
        final LangInfoModel model = mList.get(position);
        if (model.iscare() == true){
            return;
        }
        model.setIscare(true);
        mList.set(position,model);
        notifyDataSetChanged();

        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put("authorid", model.getUserid());
        String url = "miniapp/"+"langappid"+"/addcare.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    //点击了详情
    private void onClickDetail(int position){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        LangInfoModel model = mList.get(position);
        Intent intent = new Intent(mActivity, LangDetailActivity.class);
        Bundle bundle=new Bundle();
        bundle.putSerializable("model", model);//序列化
        intent.putExtras(bundle);//发送数据
        mActivity.startActivity(intent);
    }

    //点击了分享
    private void onClickShare(int position, View v){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        final LangInfoModel model = mList.get(position);
        Intent intent = new Intent(mActivity, LangDetailActivity.class);
        Bundle bundle=new Bundle();
        bundle.putSerializable("model", model);//序列化
        bundle.putBoolean("share",true);
        intent.putExtras(bundle);//发送数据
        mActivity.startActivity(intent);

    }

    //笔芯了收藏
    private void onClickCollect(final int position){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(mActivity,LoginActivity.class);
            mActivity.startActivity(intent);
            return;
        }
        final LangInfoModel model = mList.get(position);
        if (model.iscollect() == true){//修改二
            model.setIscollect(false);
            if (model.getCollectcount() > 0){
                model.setCollectcount(model.getCollectcount()-1);
            }
            mList.set(position,model);
            notifyDataSetChanged();
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            map.put("id", model.getLangid());
            String url = "miniapp/"+"langappid"+"/cancleCollect.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    Log.e("TAG","笔芯结果："+data);
                }

                @Override
                public void onError(String msg) {
                }
            });
            return;
        }
        model.setIscollect(true);
        model.setCollectcount(model.getCollectcount()+1);
        mList.set(position,model);
        notifyDataSetChanged();

        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put("sourceid", model.getLangid());
        map.put(APIKey.typeKey,"1");
        String url = "miniapp/"+"langappid"+"/addcollection.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                Log.e("TAG","收藏结果："+data);
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

    //点击了笔芯
    private void onClickLike(final int position){
        if (mActivity == null){
            return;
        }
        if (mList == null || mList.size() == 0){
            return;
        }
        if (CommonUtils.isLogin() == false){
            Intent intent = new Intent(mActivity,LoginActivity.class);
            mActivity.startActivity(intent);
            return;
        }
        final LangInfoModel model = mList.get(position);
        if (model.islike() == true){//修改之一
            model.setIslike(false);
            if (model.getLikecount() > 0){
                model.setLikecount(model.getLikecount()-1);
            }
            mList.set(position,model);
            notifyDataSetChanged();
            final HashMap<String, String> map = new HashMap<String, String>();
            map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
            map.put("id", model.getLangid());
            String url = "miniapp/"+"langappid"+"/canclelike.do";
            HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
                @Override
                public void onSuccess(String data) {
                    Log.e("TAG","笔芯结果："+data);
                }

                @Override
                public void onError(String msg) {
                }
            });
            return;
        }
        model.setIslike(true);
        model.setLikecount(model.getLikecount()+1);
        mList.set(position,model);
        notifyDataSetChanged();

        final HashMap<String, String> map = new HashMap<String, String>();
        map.put(APIKey.tokenKey, CustomApplication.loginModel.getToken());
        map.put("id", model.getLangid());
        map.put(APIKey.typeKey,"1");
        map.put("answerid","0");
        String url = "miniapp/"+"langappid"+"/langcl.do";
        HttpsUtils.miniAppDo(map, url, new HttpCallBack() {
            @Override
            public void onSuccess(String data) {
                Log.e("TAG","笔芯结果："+data);
            }

            @Override
            public void onError(String msg) {
            }
        });
    }

}
